home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!tsys.demon.co.uk
- From: Tom Wheeley <tomw@tsys.demon.co.uk>
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: H E L P
- Date: Sat, 06 Apr 96 13:05:00 GMT
- Organization: City Zen FM
- Distribution: world
- Message-ID: <828795900snz@tsys.demon.co.uk>
- References: <N.040296.013047.18@DynamicPPP-185.HIP.CAM.ORG> <Pine.A32.3.91.960402135001.121719B-100000@green.weeg.uiowa.edu> <4js6jh$ndr@solutions.solon.com> <Pine.A32.3.91.960402163729.88458A-100000@black.weeg.uiowa.edu>
- Reply-To: tomw@tsys.demon.co.uk
- X-NNTP-Posting-Host: tsys.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.30
- X-Sig-By: Tomsystems Quote v1.2. (c)1996 Tom Wheeley, tomw@tsys.demon.co.uk
- X-Mail2News-Path: tsys.demon.co.uk
-
- In article <Pine.A32.3.91.960402163729.88458A-100000@black.weeg.uiowa.edu>
- robinson@blue.weeg.uiowa.edu "The Amorphous Mass" writes:
-
- > On 2 Apr 1996, Peter Seebach wrote:
- >
- > > Obviously, if you're assuming age, you would have no more than about 150 ifs
- > > to test, (assuming humans), and if you just want to do it for 45, it's even
- > > easier.
- >
- > That's true. Actually, something like
- >
- > char *smileys[] = { "", ":-)", ":-) :-)", ":-) :-) :-)" /* etc. */ };
- >
- > would greatly speed up the programs performance and clarity --
- > it would be as simple as:
- >
- > #include <stdio.h>
- > int main(void)
- > {
- > int age;
- > scanf("%d", &age);
- > if (age < 0 || age > 150) printf("Very funny, dogbreath.\n");
- > else printf("You're %d years young!\n\n%s\n", age, smileys[age]);
- > return 0;
- > }
- >
- > /Tres elegant/, blazingly fast, and much more /sophistique/ than a lowly
- > while() loop.
-
- But of course, the best way to write such a program would be using another
- C program. Would you use a loop for this one? :-)
-
- .splitbung
- --
- * TQ 1.0 * The 'Just So Quotes'.
- "I'd rather have a bottle in front of me than a frontal lobotomy"
-